using Game.Networking;
using Game.Networking.Events;
using Game.Networking.Server;
using SMGCore.EventSys;

namespace Game.UI {
	public sealed class ServerChatReceiver : ChatReceiver {
		public override void Init() {
			EventManager.Subscribe<ChatMessageReceived>(this, OnChatMessageReceived);
		}

		public override void DeInit() {
			EventManager.Unsubscribe<ChatMessageReceived>(OnChatMessageReceived);
		}

		public override void SendMessage(string message) {
			ServerChatManager.Instance.BroadcastFromServer(ChatMessageType.Info, message);
		}

		void OnChatMessageReceived(ChatMessageReceived e) {
			OnMessageReceived.Fire(e.Message);
		}
	}
}
